let app = getApp();
Component({
  /**
   * 组件的属性列表
   */
        properties: {
            value: {
                type: String,
                default: ""
            },
            title: {
                type: String,
                default: "图片上传"
            },
            numberShow: {
                type: [ String, Boolean ],
                default: !0
            },
            max: {
                type: [ String, Number ],
                default: 5
            },
            disabled: {
                type: Boolean,
                default: !1
            },
            col: {
                type: Number,
                default: 5
            }
        },
        data:{
            imageList: [],
            currentVal: "",
            max:3
        },
        computed: {
            showTitle: function() {
                return !(0, a.isNullOrEmpty)(this.title);
            }
        },
        watch: {
            value: function(t, e) {
                this.currentVal = t, this.initData();
            }
        },
        methods: {
            initData: function() {
                (0, a.isNullOrEmpty)(this.currentVal) ? this.imageList = [] : (this.imageList = [], 
                this.imageList = this.currentVal.split(","));
            },
            chooseImage: function() {
                var e = this.data;
                e.disabled || wx.chooseImage({
                    count: Number(e.max),
                    sizeType: [ "original", "compressed" ],
                    sourceType: [ "album", "camera" ],
                    success: function(n) {
                        var a = Number(e.max);
                        if (n.tempFilePaths.length > a - e.imageList.length) return wx.showToast({
                            title: "最多上传".concat(a, "张"),
                            icon: "none",
                            duration: 2e3
                        }), !1;
                        n.tempFilePaths.forEach(function(n) {
                            wx.showLoading({
                                title: "正在上传...."
                            }), i.default.upload("user_cert", "", n, function(n) {
                                if (wx.hideLoading(), "success" === n.code) {
                                    var i = n.data.uploadFileId + "@" + n.data.fileName;
                                    e.imageList.push(i), e.addImgKey(i), e.$emit("input", e.currentVal);
                                }
                            });
                        });
                    },
                    complete: function(t) {},
                    fail: function(t) {}
                });
            },
            addImgKey: function(t) {
                (0, a.isNullOrEmpty)(this.currentVal) ? this.currentVal = t : this.currentVal += "," + t;
            },
            viewImage: function(e) {
                var n = this, i = this.imageList.map(function(t) {
                    return n.$getViewUrl(t);
                });
                t.previewImage({
                    urls: i,
                    current: e
                });
            },
            delImg: function(t) {
                if (!this.disabled) {
                    this.imageList.splice(t, 1);
                    var e, n = this.currentVal.split(",");
                    e = (n = n.filter(function(e, n) {
                        return n !== t;
                    })).join(","), this.currentVal = e, this.$emit("input", e);
                }
            }
        }
})